package com.krain.ddbb.fragment;

import android.app.Activity;
import android.widget.Button;
import android.widget.EditText;
import android.widget.MediaController;
import android.widget.TextView;

import com.krain.ddbb.R;
import com.krain.ddbb.entity.AppApi;
import com.krain.ddbb.entity.BaseEntity;
import com.krain.ddbb.entity.UserAccountBean;
import com.krain.ddbb.entity.UserCardBean;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Background;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.Extra;
import org.androidannotations.annotations.FragmentArg;
import org.androidannotations.annotations.UiThread;
import org.androidannotations.annotations.ViewById;

/**
 * Created by 胡亚敏 on 2016/3/15 0015.
 */
@EFragment(R.layout.view_cardbinded)
public class BindCardFragment extends BaseFragment {
    @ViewById(R.id.act_bind_bankname)
    TextView cardname;
    @ViewById(R.id.act_bind_banknum)
    TextView cardNum;
    @ViewById(R.id.act_bind_owner)
    TextView cardOwner;
    int mID;
    @FragmentArg("bean")
    UserAccountBean bean;


    @Click(R.id.act_unbindcard_submit)
    void submitClick() {
        unBindCard();
    }

    @AfterViews
    void afterView(){
        mID = bean.getBank_id();
        cardname.setText(bean.getBank_fullname());
        cardNum.setText(bean.getBank_number());
        cardOwner.setText(bean.getBank_fullname());
    }




    @Background
    void unBindCard(){
        mBaseActivity.showProgressDialog();
        BaseEntity entity = AppApi.getsInstance(mBaseActivity).unBindBank(app.getmUserinfo().getAccess_token(),mID);
        if (entity != null) {
            baseUtil.showSnackBar(mBaseActivity,"解绑成功");
            mBaseActivity.setResult(Activity.RESULT_OK);
            mBaseActivity.finish();
        }
        mBaseActivity.dismissProgressDialog();
    }
}
